package com.wzy.observerPattern;

import java.util.Vector;

/**
 * @Author: wzy
 * @Date: 2022/10/11/9:26
 * @Description: 被观察者
 */
public abstract class Subject {
    private Vector<ObServer> obs = new Vector<>();

    public Vector<ObServer> getObs() {
        return obs;
    }

    public void setObs(Vector<ObServer> obs) {
        this.obs = obs;
    }

    public void addObserver(ObServer obs) {
        this.obs.add(obs);
    }

    public void delObserver(ObServer obs) {
        this.obs.remove(obs);
    }

    protected void notifyObs() {
        obs.forEach(ObServer::update);
    }

    public abstract void doSomething();
}
